#ifndef DSM_H_
#define DSM_H_

/******************************************************************************
 *  Include Files
 *****************************************************************************/
#include <stdint.h>
#include <stddef.h>

/******************************************************************************
 *  Macro Definitions
 *****************************************************************************/

/******************************************************************************
 *  Const Definitions
 *****************************************************************************/
typedef enum {
  DSM_FaultType_None = 0x00,
  DSM_FaultType_RVSB = 0x01,
  DSM_FaultType_IRRV = 0x02,
  DSM_FaultType_SUM = 0x03,
} DSM_FAULTTYPE;

typedef enum {
  DSM_ErrReactn_NoActn = 0x00,
  DSM_ErrReactn_Limit_Speed = 0x01,
  DSM_ErrReactn_Limit_Torque = 0x02,
  DSM_ErrReactn_Limit_Voltage = 0x03,
  DSM_ErrReactn_Limit_Current = 0x04,
  DSM_ErrReactn_Standby = 0x05,
  DSM_ErrReactn_Stop = 0x06,
  DSM_ErrReactn_SUM = 0x07,
} DSM_ERRREACTNS;

/*****************************************************************************
 *  Type Definitions
 *****************************************************************************/
typedef struct {
  const uint8_t nNo_C;
  uint8_t stAdded_DFC_List;
  uint8_t stFault[DSM_FaultType_SUM];
  uint8_t stFaultState;
  const uint8_t stFault_Type_C;
  const uint8_t stFault_ErrReactn_C;
  uint16_t cntrDeb;
  const uint16_t cntrDebMax_C;
} DSM_DFC;

/*****************************************************************************
 *  Extern Variables
 *****************************************************************************/
extern uint32_t DSM_FaultState_Boardcast_RVSB;
extern uint32_t DSM_FaultState_Boardcast_IRRV;
extern uint8_t DSM_stErrReactn[DSM_ErrReactn_SUM];

/*****************************************************************************
 *  Function Prototypes
 *****************************************************************************/
extern void DSM_Trigger(DSM_DFC *DFC, uint8_t OK_NG);
extern void DSM_ErrReactn_Main(void);

#endif /* DSM_H_ */
